#ifndef NETSERVER_H
#define NETSERVER_H

#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
class NetServer : public QObject
{
    Q_OBJECT

public:
    explicit NetServer(QObject *parent = nullptr);

    void startListen();//开始监听

    void sendStopToCar(const int &carId);

    void sendStartToCar(const int &carId);
signals:
    void signal_addCar(const int &id);
    void signal_updateCar(const int &id,const int &road_id,
                           const float &duration);

    void signal_getCrossState(const int &road_id,bool &ok);
public slots:
    void slot_newConnection();
    void slot_readyRead();

private:
    QList<QJsonObject>splitJsonObject(const QByteArray &data);
    QTcpServer server;
    QList<QTcpSocket *>list_socket;
};

#endif // NETSERVER_H
